#include <sys/ipc.h>
#include <sys/shm.h>

main()
{
    int shmid;
    char *mem;

    if ((shmid = shmget(getpid(),4096,IPC_CREAT|0600)) == -1)
    {
        printf("OOPS: shmget failed %d\n",shmid);
	exit(0);
    }
    if ((mem = (char *)shmat(shmid,NULL,0)) == (char *)-1)
    {
        printf("OOPS: shmat failed %d\n",mem);
	exit(0);
    }
    shmctl(shmid,IPC_RMID,0);
    /* shmdt(mem); */
    mem[4000] = 'a';
    printf("mem4000=%c\n",mem[4000]);
}
